﻿Imports extranet.BE
Imports extranet.BC

Partial Class NavegacaoMaster
  Inherits System.Web.UI.MasterPage

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    If DirectCast(Session("objBEUsuario"), BEUsuario) Is Nothing Then
      lblUsuario.Text = "Usuário Não Logado"
    Else
      Dim objBEUsuario As BEUsuario = Session("objBEUsuario")
      lblUsuario.Text = objBEUsuario.Nome
      If objBEUsuario.GrupoAcesso.Nome.ToUpper() = "ADMIN" Then
        lnkTrocarModo.Visible = True
      Else
        lnkTrocarModo.Visible = False
      End If
    End If

    If Not IsPostBack Then
      Dim objBERanking As BERanking = BCRanking.SelecionarRanking("1")

      grvRanking.DataSource = BCRankeado.LerRankeados(objBERanking.Planilha, True)
      grvRanking.DataBind()

      For i As Integer = 0 To grvRanking.Rows.Count - 1
        Select Case i
          Case 0
            Dim imgOuro As ImageButton = grvRanking.Rows(i).FindControl("imgOuro")
            imgOuro.Visible = True
          Case 1
            Dim imgPrata As ImageButton = grvRanking.Rows(i).FindControl("imgPrata")
            imgPrata.Visible = True
          Case 2
            Dim imgBronze As ImageButton = grvRanking.Rows(i).FindControl("imgBronze")
            imgBronze.Visible = True
          Case Else
            Dim lblPos As LinkButton = grvRanking.Rows(i).FindControl("lblPos")
            lblPos.Visible = True
            lblPos.Text = (i + 1).ToString()
        End Select
      Next
    End If
  End Sub

  Protected Sub grvRanking_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles grvRanking.RowEditing
    Response.Redirect("~/ranking/PubRnkVisualizarRanking.aspx")
  End Sub

  Protected Sub imgHeader_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgHeader.Click
    Response.Redirect("~/ranking/PubRnkVisualizarRanking.aspx")
  End Sub

  Protected Sub lnkTrocarModo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkTrocarModo.Click
    Response.Redirect("~/AdmEntrada.aspx")
  End Sub

  Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
    Response.Redirect("~/PubEntrada.aspx")
  End Sub

End Class

